import { employeeBonusSalarySalaryListExportGET } from "@/api/finance";
import ExportButton from "@/business-components/export-button";
import Report, {
  IColumns,
  IReportFormItem,
} from "@/business-components/report";
import { healthRecordListGET } from "@/models/workshop/api/healthRecord/healthRecordListGET";
import { HealthArchiveRecordVo } from "@/models/workshop/model/HealthArchiveRecordVo";
import React, { Component } from "react";

export interface ReportListState {
  list: HealthArchiveRecordVo[];
  filter: IReportFormItem[];
  columns: IColumns<HealthArchiveRecordVo>[];
}

/** 测试报表 */
export default class ReportList extends Component<any, ReportListState> {
  state: ReportListState = {
    list: [],
    filter: [
      {
        key: ["startTime", "endTime"],
        label: "结算时间",
        type: "date-range",
      },
      {
        key: "reportType",
        label: "上报状态",
        type: "select",
        hasAll: false,
        list: [
          { id: "1", value: "未上报" },
          { id: "2", value: "已上报" },
          { id: "3", value: "上报失败" },
        ],
      },
      {
        key: "keyNameOrCompany",
        label: "姓名/单位",
        type: "input",
      },
    ],
    columns: [],
  };

  reportRef: React.RefObject<Report<HealthArchiveRecordVo>> = React.createRef();

  render() {
    return (
      <Report<HealthArchiveRecordVo>
        tableName="HEALTH_ARCHIVE_RECORD_LIST"
        ref={this.reportRef}
        onQuery={(list) => this.setState({ list })}
        request={(params) => healthRecordListGET(params)}
        form={this.state.filter}
        columns={this.state.columns}
        toolbar={(params) => (
          <ExportButton
            request={() => employeeBonusSalarySalaryListExportGET(params)}
            name="工资报表.xlsx"
          />
        )}
      />
    );
  }
}
